package com.daxt.utils;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class LocalDateTimeUtil {

	public static String getNowTimeYMD(){
		LocalDateTime nowTime = LocalDateTime.now();
		int year = nowTime.getYear();
		int month = nowTime.getMonthValue();
		int day = nowTime.getDayOfMonth();
		return year+"-"+(month<10?"0"+month:month)+"-"+(day<10?"0"+day:day);
	}
	public static String getNowTimeYMDMS(){
		LocalDateTime nowTime = LocalDateTime.now();
		int year = nowTime.getYear();
		int month = nowTime.getMonthValue();
		int day = nowTime.getDayOfMonth();
		int m=nowTime.getMinute();
		int s=nowTime.getSecond();
		return year+"-"+(month<10?"0"+month:month)+"-"+(day<10?"0"+day:day)+" "+(m<10?"0"+m:m)+":"+(s<10?"0"+s:s);
	}
	public static String getNowTimeYMDMS1(){
		LocalDateTime nowTime = LocalDateTime.now();
		int year = nowTime.getYear();
		int month = nowTime.getMonthValue();
		int day = nowTime.getDayOfMonth();
		int h=nowTime.getHour();
		int m=nowTime.getMinute();
		int s=nowTime.getSecond();
		
		return year+""+(month<10?"0"+month:month)+""+(day<10?"0"+day:day)+""+(m<10?"0"+m:m)+""+(h<10?"0"+h:h)+""+(s<10?"0"+s:s);
	}
	
	public static int getNowTimeMouth(String date){
		
		LocalDate parse = LocalDate.parse(date, DateTimeFormatter.ofPattern("yyyyMMdd"));
		
		int month = parse.getMonthValue();
		return month;
	}
	/*public static void main(String[] args) {
		try {
		//System.out.println(LocalDateTimeUtil.getNowTimeMouth("20150932"));
		//System.out.println(LocalDateTimeUtil.getNowTimeMouth("20150932"));
		System.out.println(LocalDateTime.now());
		}catch (Exception e) {
			System.out.println("2222");
		}
	}*/
}
